<template>
  <div class="view-container">
    <el-button @click="toAddPage">添加</el-button>
    <el-button @click="dels">删除</el-button>
    <section class="table-container">
      <el-table
        ref="table"
        :data="tableData"
        stripe
        border
        @select="rowID"
        @row-click="handleRowClick"
      >
        <el-table-column type="selection" align="center"/>
        <el-table-column label="标题">
          <template slot-scope="s">
            <el-link @click="showDetail(s.row.infoId)">{{s.row.infoTitle}}</el-link>
          </template>
        </el-table-column>
        <el-table-column prop="infoType" label="类别" align="center" width="60"/>
        <el-table-column prop="creatorName" label="发布人" align="center" width="80"></el-table-column>
        <el-table-column prop="departName" label="所在部门" align="center" width="100"/>
        <el-table-column prop="created" label="发布时间" align="center" width="100" sortable></el-table-column>
      </el-table>
    </section>
    <footer>
      <el-pagination
        :page-sizes="[10, 20, 50, 100]"
        layout="total, sizes, prev, pager, next, jumper"
        :total="page.total"
        :page-size="page.size"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
      />
    </footer>
  </div>
</template>

<script>
  import wenXuanAPI from '@/api/portal/wenXuan'
  import listMixin from '@/mixin/listMixin'
  import ListHeader from '@/common/ListHeader'
  export default {
    name: 'WenXuanList',
    mixins: [listMixin],
    data() {
      return {
        mixinParams: {
          addUrl:'/portal/wen-xuan-save/null',
          editUrl:'/portal/wen-xuan-save/',
          propertyName: 'infoId',
          API: wenXuanAPI,
        },
        ids:[]
      }
    },
    created() {
      this.fetchData()
    },
    methods: {
      fetchData(){
        wenXuanAPI.list(this.page).then(res=>{
          console.log('wenXuanAPI.list',res)
          this.tableData = res.records
          this.page.total = res.total
        })
      },
      showDetail(id){

      },

      //获取ID
      rowID(row){

        for(const items of row){
          this.ids.push(items.infoId)
        }

        console.log(this.ids)

      },


      //删除
      dels(){
        wenXuanAPI.deles(this.ids).then(res=>{
          console.log("删除成功")
          this.fetchData()
        })
      }


    }
  }
</script>

<style scoped lang="scss">

</style>
